package jp.kiroru_inc.rs_hello_world;

import jp.kiroru_inc.rs_hello_world.R;
import jp.kiroru_inc.rs_hello_world.ScriptC_HelloWorldScript;

import android.content.Context;
import android.content.res.Resources;
import android.renderscript.Allocation;
import android.renderscript.Float2;
import android.renderscript.Font;
import android.renderscript.RenderScriptGL;

/**
 * @author Selphy
 */
public class HelloWorldScript {
	private ScriptC_HelloWorldScript script;
	private Allocation text;
	private Font font;
	
	protected HelloWorldScript(RenderScriptGL rs, final Context c, Resources res) {
		script = new ScriptC_HelloWorldScript(rs, res, R.raw.helloworldscript);
		
		text = Allocation.createFromString(rs, "Hello World", Allocation.USAGE_SCRIPT);
		font = Font.create(rs, res, "fantasy", Font.Style.NORMAL, 20);
		script.set_gFont(font);
		script.set_gText(text);
		
		rs.bindRootScript(script);
	}
	
	protected void touchEvent(float x, float y) {
		script.invoke_setTouchPosition(new Float2(x, y));
	}
}